using System.ComponentModel.DataAnnotations;

namespace BasicData.API.Dtos
{
    /// <summary>
    /// 验证码生成请求DTO
    /// </summary>
    public class CaptchaGenerateRequest
    {
        /// <summary>
        /// 验证码宽度，默认120
        /// </summary>
        public int Width { get; set; } = 120;

        /// <summary>
        /// 验证码高度，默认40
        /// </summary>
        public int Height { get; set; } = 40;

        /// <summary>
        /// 验证码长度，默认4
        /// </summary>
        public int Length { get; set; } = 4;
        
        /// <summary>
        /// 过期时间（分钟），默认5分钟
        /// </summary>
        public int ExpireMinutes { get; set; } = 5;
        
        /// <summary>
        /// 干扰线数量，默认5条
        /// </summary>
        public int NoiseLineCount { get; set; } = 5;
        
        /// <summary>
        /// 噪点数量，默认50个
        /// </summary>
        public int NoisePointCount { get; set; } = 50;
        
        /// <summary>
        /// 验证失败次数限制，默认5次
        /// </summary>
        public int MaxFailCount { get; set; } = 5;
    }

    /// <summary>
    /// 验证码生成响应DTO
    /// </summary>
    public class CaptchaGenerateResponse
    {
        /// <summary>
        /// 验证码图片的Base64字符串，包含data:image/png;base64,前缀
        /// </summary>
        public string ImageBase64 { get; set; } = string.Empty;

        /// <summary>
        /// 验证码标识符（用于验证时识别）
        /// </summary>
        public string CaptchaId { get; set; } = string.Empty;

        /// <summary>
        /// 过期时间（秒）
        /// </summary>
        public int ExpireSeconds { get; set; } = 300;
    }

    /// <summary>
    /// 验证码刷新请求DTO
    /// </summary>
    public class CaptchaRefreshRequest
    {
        /// <summary>
        /// 原验证码标识符
        /// </summary>
        [Required(ErrorMessage = "验证码标识符不能为空")]
        public string CaptchaId { get; set; } = string.Empty;
        
        /// <summary>
        /// 验证码宽度，默认120
        /// </summary>
        public int Width { get; set; } = 120;

        /// <summary>
        /// 验证码高度，默认40
        /// </summary>
        public int Height { get; set; } = 40;

        /// <summary>
        /// 验证码长度，默认4
        /// </summary>
        public int Length { get; set; } = 4;
        
        /// <summary>
        /// 过期时间（分钟），默认5分钟
        /// </summary>
        public int ExpireMinutes { get; set; } = 5;
        
        /// <summary>
        /// 干扰线数量，默认5条
        /// </summary>
        public int NoiseLineCount { get; set; } = 5;
        
        /// <summary>
        /// 噪点数量，默认50个
        /// </summary>
        public int NoisePointCount { get; set; } = 50;
    }

    /// <summary>
    /// 验证码验证请求DTO
    /// </summary>
    public class CaptchaVerifyRequest
    {
        /// <summary>
        /// 验证码标识符
        /// </summary>
        [Required(ErrorMessage = "验证码标识符不能为空")]
        public string CaptchaId { get; set; } = string.Empty;

        /// <summary>
        /// 用户输入的验证码
        /// </summary>
        [Required(ErrorMessage = "验证码不能为空")]
        [StringLength(10, MinimumLength = 1, ErrorMessage = "验证码长度必须在1-10个字符之间")]
        public string CaptchaCode { get; set; } = string.Empty;
    }

    /// <summary>
    /// 验证码验证响应DTO
    /// </summary>
    public class CaptchaVerifyResponse
    {
        /// <summary>
        /// 验证是否成功
        /// </summary>
        public bool IsValid { get; set; }

        /// <summary>
        /// 验证结果消息
        /// </summary>
        public string Message { get; set; } = string.Empty;
        
        /// <summary>
        /// 剩余尝试次数
        /// </summary>
        public int RemainingAttempts { get; set; } = 0;
    }
} 